<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.SQLException" %>
<%
	request.setCharacterEncoding("utf-8");
	String seq=request.getParameter("seq");
	String passwd = request.getParameter("passwd");	
	Connection conn =null;
	PreparedStatement pstmt = null; 

	String driver = "oracle.jdbc.driver.OracleDriver";
	String url = "jdbc:oracle:thin:@localhost:1521:orcl";
	String user = "scott";
	String password = "tiger";
	
	String subject = "";
	String writer ="";
	String mail ="";
	
	int flag=2; //기본 에러
	
	try{
		Class.forName(driver);
		conn=DriverManager.getConnection(url, user, password);
		String sql = "delete from board1 where seq=? and passwd=?";
		pstmt = conn.prepareStatement(sql);
		pstmt.setString(1, seq);
		pstmt.setString(2, passwd);
	
		int result = pstmt.executeUpdate();
		if(result==1){
			flag=0;
		}else if(result==0){
			flag=1;
		}
		
	}catch(ClassNotFoundException e){
		
	}catch(SQLException e){
		
	}finally{
		if(pstmt!=null) pstmt.close();
		if(conn!=null) conn.close();
	}
	out.print("<script language='javascript'>");
	if(flag==0){
		out.print("alert('"+seq+"번 글이 삭제 되었습니다.');");
		out.print("location.href='board_list1.jsp';");
	}else if(flag==1){
		out.print("alert('비밀 번호가 잘못 되었습니다.');");
		out.print("history.back();");
	}
	out.print("</script>");
	

%>